<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="选择业务单" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<link href="/css/Query.css" rel="stylesheet" type="text/css">
<script src="/js/QueryList.js"></script>
<script language="javascript">
	function doGo(pageIndex){
		var searchKey=encodeURIComponent("${searchKey}");
		var searchType="${searchType}";
		var tsId="${tsId}";
		window.location="/make/BusinessBillListForSelect.ihtm?ts_id="+tsId+"&search_type="+searchType+"&search_key="+searchKey+"&current_page="+pageIndex;
	}
	function doJump(pageIndex){
		if(window.event.keyCode==13){
			doGo(pageIndex);
		}
	}
	function doSearch(){
		var searchKey=encodeURIComponent(document.getElementById("search_key").value.trim());
		var searchType="${searchType}";
		var tsId="${tsId}";
		if(searchKey!=''){
			window.location="/make/BusinessBillListForSelect.ihtm?ts_id="+tsId+"&search_type="+searchType+"&search_key="+searchKey;
		}
	}
	function doSelect(index){
		var ob_arr = document.getElementsByName("query_checkbox");
		var arr;
		if (ob_arr.length>=index){
			arr=new Array(ob_arr[index-1].value,ob_arr[index-1].getAttribute("bill_code"),ob_arr[index-1].getAttribute("content"),ob_arr[index-1].getAttribute("amount"));
			parent.popRetVal=arr;
			parent.ClosePop();
		}
	}
	
	function DoubleClick(it){
		var ob_arr = document.getElementsByName("query_checkbox");
		var arr;
		if(ob_arr.length>=it.getAttribute("index")){
			var obj=ob_arr[it.getAttribute("index")-1];
			arr=new Array(obj.value,obj.getAttribute("bill_code"),obj.getAttribute("content"),obj.getAttribute("amount"));
		}
		if(arr==null){
			return;
		}
		parent.popRetVal=arr;
		parent.ClosePop();
	}
	function doBusinessItemList(billId,billCode){
		var url="/business/BusinessBillItemListAlone.ihtm?id="+billId+"&mark="+encodeURIComponent("业务单："+billCode);
		showWin(900,600,url);
	}
	function doCancel(){
		parent.ClosePop();
	}
	function doInit(){
		Window_Onload();
		document.getElementById("search_key").focus();
	}
	function checkSearchKey(){
		if(window.event.keyCode==13){
			doSearch();
		}
	}
</script>
</head>
<body oncontextmenu="return false" onload="doInit();"  class="sheet">
<div class="sheet-main" style="width:855px">
  <div class="sheet-top">
    <div class="content">
      <h2>选择业务单</h2>
      <p><c:if test="${searchType!='STO'}">鼠标双击可以选中业务单</c:if><c:if test="${searchType=='STO'}">蓝色表示业务单已开过出库单</c:if></p>
    </div>
  </div>
  <div class="sheet-list">
    <div class="search-business">
      <div class="content">
        <table width="100%">
          <tbody>
            <tr>
              	<td align="right">
					<input type="text" class="TextBox" id="search_key" name="search_key" onKeyUp="checkSearchKey();" style="width:100px" value="${searchKey}" title="以客户名称、客户拼音字头、摘要、业务单号进行模糊查询">
					<input type="button" class="buttom search-but" value="查询" onClick="doSearch();" title="以客户名称、客户拼音字头、摘要、业务单号进行模糊查询">	              
				</td>
            </tr>    
           </tbody>      
        </table>
      </div>
       
      <div class="table-list">
		<table width="100%">      
			<tr>
				<th width="14"></th>
				<th  width="16%">单号</th>
				<th  width="10%">订货日期</th>
				<th  width="20%">订货单位</th>
				<th  width="22%">摘要</th>
				<th  width="10%">交货日期</th>
				<th  width="10%">业务员</th>
				<th  width="12%">操作</th>
			</tr>
			<c:forEach var="item" items="${qr.list}" varStatus="i">
				<c:if test="${(i.index mod 2)==0}"><c:set var="trClass" value="query_list_data_tr1" /></c:if>
				<c:if test="${(i.index mod 2)!=0}"><c:set var="trClass" value="query_list_data_tr2" /></c:if>
				<c:set var="defaultFontColor" value="#000000" />
				<c:if test="${searchType=='STO'}"><c:if test="${item[8]!=null}"><c:set var="defaultFontColor" value="blue" /></c:if></c:if>
				<tr class="${trClass}" index="${i.index+1}" style="color:${defaultFontColor};cursor:pointer;" defaultFontColor="${defaultFontColor}" ondblclick='javascript:DoubleClick(this)' onClick='javascript:ClickCheck(this)' onmouseout='javascript:mouseout(this)' onmouseover='javascript:mouseover(this)'>
					<td><input type="radio" name='query_checkbox' value="${item[0]}" bill_code="${item[1]}" content="${item[4]}" amount="${item[5]}"></td>
					<td>${item[1]}</td>
					<td><fmt:formatDate value="${item[2]}" pattern="yyyy-MM-dd"/></td>
					<td><c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';NO_CLIE_NAME;')==-1}">${item[3]}</c:if></td>
					<td>${item[4]}</td>
					<td>
						<c:if test="${item[6]!=null}"><fmt:formatDate value="${item[6]}" pattern="yyyy-MM-dd"/></c:if>
					</td>
					<td>${item[7]}</td>
					<td>
						<a href="javascript:doSelect('${i.index+1}');">选择</a>
						<a href="javascript:doBusinessItemList('${item[0]}','${item[1]}');">订货明细</a>
					</td>
				</tr>
			</c:forEach>
		</table>
		<%@include file="../inc/Pages.jsp"%>
      </div>    
    </div>
  </div>
</div>
</html>